<%@page import="warehouse.OrderBean"%>
<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加订单的功能实现</title>
</head>
<body>

<%
	String clientNoString = request.getParameter("clientNo");
	String orderDateString = request.getParameter("orderDate");
	
	String[] cargoStringList = request.getParameterValues("cargoNo");
	String[] purchaseNumStringList = request.getParameterValues("purchaseNum");
	
	//如果参数不足则跳转回去
	if(clientNoString==null||orderDateString==null||cargoStringList==null||purchaseNumStringList==null){
		response.sendRedirect("order_form.jsp");
		return;
	}
	//客户编号转化
	int clientNo = Integer.valueOf(clientNoString);
	
	//日期转换
	Date orderDate = Date.valueOf(orderDateString);
	//货物编号转化
	int[] cargoNoList = new int[cargoStringList.length];
	for(int i=0;i<cargoStringList.length;i++){
		cargoNoList[i] = Integer.valueOf(cargoStringList[i]);
	}
	//购买量转化
	int[] purchaseNumList = new int[purchaseNumStringList.length];
	for(int i=0;i<purchaseNumStringList.length;i++){
		purchaseNumList[i] = Integer.valueOf(purchaseNumStringList[i]);
	}
	
	//添加订单
	OrderBean.addOrder(clientNo, orderDate, cargoNoList, purchaseNumList);
	
	response.sendRedirect("order_list.jsp");
%>
</body>
</html>